#pragma once

#include "RenderProcess.h"
#include "../../Render/Texture/ColorRenderTarget.h"
#include "../../Render/Tradition/RHIRenderPass.h"
#include "../../Render/Tradition/GraphicsPipeline.h"
#include "../../Render/Texture/ColorRenderTarget.h"
#include "../../Render/Shader/RHIDescriptor.h"
#include "../Scene/Entity.h"
#include "../../Render/RenderState.h"
#include "../../Render/Shader/GlobalShader.h"

class CoordinateProcess : public RenderProcess
{
	DECLARE_PROCESS(CoordinateProcess)

	struct UboCoordinate
	{
		glm::mat4 model;
		glm::mat4 view;
		glm::mat4 proj;
	};

	struct VertexCoordinate
	{
		glm::vec3 pos;
		glm::vec4 color;
	};

public:

	CoordinateProcess();

	CoordinateProcess(const std::string& colorProcess);

	CoordinateProcess(const std::string& colorProcess, const std::string& colorName);

	void UpdateColorRenderTarget(const std::string& colorProcess, const std::string& colorName);

protected:

	virtual void OnInit() override;

	virtual void OnTick(float deltaTime) override;

	virtual void OnResize() override;

	virtual void OnFrameEnd() override;

protected:

	// Which process to get the color render target
	std::string mColorProcess;

	std::string mColorName;

	bool mColorDirty;

	Entity* mCoordinateEntity;

	DescriptorMask mPaintDescriptorMask;

	RefCountPtr<RHIBuffer> mVertexBuffer;

	RefCountPtr<RHIBuffer> mIndexBuffer;

	RefCountPtr<RHIBuffer> mUboBuffer;

	RefCountPtr<RHIDescriptor> mPaintDescriptor;

	RefCountPtr<GraphicsPipeline> mPaintPipeline;

	RefCountPtr<RHIRenderPass> mPaintRenderPass;

	RefCountPtr<RHIFrameBuffer> mPaintFrameBuffer;

	RefCountPtr<ColorRenderTarget> mPaintColorRenderTarget;

	DescriptorMask mQuadDescriptorMask;

	RefCountPtr<RHIDescriptor> mQuadDescriptor;

	RefCountPtr<GraphicsPipeline> mQuadPipeline;

	RefCountPtr<RHIRenderPass> mQuadRenderPass;

	RefCountPtr<RHIFrameBuffer> mQuadFrameBuffer;

	RefCountPtr<ColorRenderTarget> mQuadColorRenderTarget;

	RefCountPtr<RHISampler> mSampler;

	ShaderPtr<CoordinateQuadVertexShader> mCoordinateQuadVertexShader;

	ShaderPtr<CoordinateQuadFragmentShader> mCoordinateQuadFragmentShader;
};
